package com.heima.admin.controller;

import com.heima.admin.service.IChannelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@RequiredArgsConstructor
@Slf4j
public class ChannelController {

    private final IChannelService channelService;

    @PostMapping("/list")
    public ResponseResult channelPage(@RequestBody ChannelDto dto){
        return channelService.getChannelPage(dto);
    }

    @GetMapping("/del/{id}")
    public ResponseResult channelDelete(@PathVariable("id") Integer id){
        return channelService.channelDelete(id);
    }

    @PostMapping("/save")
    public ResponseResult channelSave(@RequestBody WmChannel wmChannel){
        return channelService.channelSave(wmChannel);
    }

    @PostMapping("/update")
    public ResponseResult channelUpdate(@RequestBody WmChannel wmChannel){
        return channelService.channelUpdate(wmChannel);
    }
}
